pkgname=ycsb
pkgver=0.15.0
pkgrel=0
arch=('i386' 'x86_64')
url="https://gitee.com/ssri-mirrors/YCSB"
pkgdesc="Yahoo! Cloud Serving Benchmark"
license=('Apache License 2.0')
depends=("mongodb")
#source=("https://gitee.com/ssri-mirrors/YCSB/releases/download/${pkgver}/${pkgname}-${pkgver}.tar.gz")
#sha256sums=('SKIP')

build() {
        which python3 > /dev/null && PYTHON3_PATH=$(which python3)
        ln -s $PYTHON3_PATH /usr/bin/python

        cd "${srcdir}"
          #本程序及如下代码仅适用于ycsb-0.15.0.tar.gz
        git clone https://gitee.com/zhai-gaoshou/ycsb-release-0.15.0.git && cd ycsb-release-0.15.0
        cat ycsb-0.15.0.tar.gz.0* > ycsb-0.15.0.tar.gz && mv ycsb-0.15.0.tar.gz .. && cd ..
        #sleep 10
        while true
        do
                if [ -e "${pkgname}-${pkgver}.tar.gz" ]
                then
                        echo "${pkgname}-${pkgver}.tar.gz is READY!"
                        break
                else
                        echo "${pkgname}-${pkgver}.tar.gz is NOT READY!!!"
                        sleep 5
                fi
        done
}

package() {
        cd "${srcdir}"
        [ -e "${pkgname}-${pkgver}" ] || tar -xvf "${pkgname}-${pkgver}.tar.gz"
        while true
        do
                if [ -e "${pkgname}-${pkgver}" ]
                then
                        echo "${pkgname}-${pkgver} is OK!"
                        break
                else
                        echo "${pkgname}-${pkgver} is NOT OK!!!"
                        sleep 5
                fi
        done

	mkdir -p "${pkgdir}/lkp/benchmarks/${pkgname}"
	cp -a "${srcdir}/${pkgname}-${pkgver}" "${pkgdir}/lkp/benchmarks/${pkgname}"
	cd "${pkgdir}/lkp/benchmarks/${pkgname}"
	ln -sf "${pkgname}-${pkgver}" "${pkgname}"
}
